import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [

    vue(), vueJsx()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "@vs": fileURLToPath(new URL("./src/views", import.meta.url)),
      "@cs": fileURLToPath(new URL("./src/components", import.meta.url))
    }
  },
  server: {
    proxy: {
      '/plus-api': {
        target: 'http://ai.question.garlicfit.com/api',
        changeOrigin: true,
        secure: false,
        rewrite: (path) => path.replace(/^\/plus-api/, '')
      },
      '/deepseek-api':{
        target: 'http://127.0.0.1:5000',
        changeOrigin: true,
        secure: false,
        rewrite: (path) => path.replace(/^\/deepseek-api/, '')
      }
    },
  },
  build: {
    target: ['es2016']
  },
  define: {
    appName: JSON.stringify('管理后台')
  }
});
